{extend name="public:public" /}
{block name="section"}
<section class="Hui-article-box">
    <nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> Banner管理 <span class="c-gray en">&gt;</span> Banner列表<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
    <div class="Hui-article">
        <article class="cl pd-20">
            <form action="" method="get">
                <!--<div class="text-c"> banner名称：-->
                    <!--<input type="text" class="input-text" style="width:250px" placeholder="Banner名称" name="name">-->
                    <!--<button type="submit" class="btn btn-success radius" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜索</button>-->
                <!--</div>-->
            </form>
            <div class="cl pd-5 bg-1 bk-gray mt-20">
                <span class="l">
                    <!--<a href="javascript:;" onclick="datadel()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a>-->
                <a href="javascript:;" onclick="member_add('添加拼团活动','/admin/collage/add','','510')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加拼团</a></span> <span class="r">共有数据：<strong>{$lists->total()}</strong> 条</span> </div>
            <div class="mt-20">
                <table class="table table-border table-bordered table-hover table-bg table-sort">
                    <thead>
                    <tr class="text-c">
                        <th>ID</th>
                        <th width="100">拼团名称</th>
                        <th width="">拼团商品</th>
                        <th width="">商品原价</th>
                        <th width="">拼团价格</th>
                        <th width="">拼团人数</th>
                        <th width="">开始时间</th>
                        <th width="">结束时间</th>
                        <th width="100">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {volist name="lists" id="v"}
                    <tr class="text-c">
                        <td>{$v->id}</td>
                        <td>{$v->collage_name}</td>
                        <td>{$v->goods_id}</td>
                        <td>{$v->goods_price}</td>
                        <td class="td-status">{$v->collage_price}</td>
                        <td>{$v->people_num}</td>
                        <td>{$v->start_time}</td>
                        <td>{$v->end_time}</td>
                        <td class="td-manage">
                            <a title="定时器验证" href="javascript:;" onclick="testTime()" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
                            <a title="编辑" href="javascript:;" onclick="member_edit('编辑','/admin/Collage/edi','{$v->id}','','510')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a>
                            <a title="删除" href="javascript:;" onclick="member_del(this,'{$v->id}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
                        </td>
                    </tr>
                    {/volist}
                    </tbody>
                </table>
                {$lists->render()}
            </div>
        </article>
    </div>
</section>
<script type="text/javascript">
    function testTime()
    {
        $.ajax({
            type:"GET",
            url : "{:url('admin/Timing/index')}",
            success:function(){

            },
            error:function(){

            }
        })
    }




    $(function(){
        // $('').dataTable({
        // 	"aaSorting": [[ 1, "desc" ]],//默认第几个排序
        // 	"bStateSave": true,//状态保存
        // 	"aoColumnDefs": [
        // 	  //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
        // 	  {"orderable":false,"aTargets":[0,8,9]}// 制定列不参与排序
        // 	]
        // });
        $('.table-sort tbody').on( 'click', 'tr', function () {
            if ( $(this).hasClass('selected') ) {
                $(this).removeClass('selected');
            }
            else {
                table.$('tr.selected').removeClass('selected');
                $(this).addClass('selected');
            }
        });
    });

    //批量删除方法
    function datadel(){
        var checkbox = $(":checked");
        var id = [];
        for (var i=0;i<checkbox.length;i++)
        {
            //如果用户选择批量删除
            if(!checkbox.eq(i).val()){
                continue;
            }
            id.push(checkbox.eq(i).val());
        }
        $.ajax({
            type:'post',
            data:{ id:id },
            url:'/admin/banner/delallitem',
            success:function(data){
                layer.msg(data.msg,{icon:1,time:2000},function() {
                    var index = parent.layer.getFrameIndex(window.name);
                    window.parent.location.reload();
                    parent.layer.close(index);
                })
            }
        });
    }

    /*用户-添加*/
    function member_add(title,url,w,h){
        layer_show(title,url,w,h);
    }
    /*用户-查看*/
    function member_show(title,url,id,w,h){
        layer_show(title,url,w,h);
    }
    /*banner图是否启用*/
    function is_use(id,use){
        var message;
        if(use == 0){
            message = '确定要启用吗';
        }else{
            message = '确定要关闭吗';
        }
        layer.confirm(message,function(index){
            $.post("/admin/banner/is_use", {id:id},function(data){
                if(data == 1){
                    layer.msg('修改成功!',{icon:1,time:1000});
                    window.parent.location.reload();
                }else{
                    layer_msg('修改成功失败',{icon:1,time:1000});
                }
            });
        });
    }


    /*用户-编辑*/
    function member_edit(title,url,id,w,h){
        layer_show(title,url+'/id/'+id,w,h);
    }
    /*密码-修改*/
    function change_password(title,url,id,w,h){
        layer_show(title,url,w,h);
    }
    /*删除Banner item*/
    function member_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            $.post("/admin/Collage/del", {id:id},function(data){
                if(data.error == 0){
                    $(obj).parents("tr").remove();
                    layer.msg(data.msg,{icon:1,time:1000});
                }else{
                    layer.msg(data.msg,{icon:2,time:1000});
                }
            });
        });
    }
</script>
{/block}

